<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/4/17 0017
 * Time: 18:01
 */

namespace app\index\controller;


use think\Controller;

class Search extends Controller
{
    public function index(){
        $param = request()->param();
        $m_id = session('member_id');
        if(!empty($m_id)){
            $member = db('member')->cache(true,60)->where('id',$m_id)->find();
            $this->assign([
                'member' => $member
            ]);
        }
        $data = db("book")
            ->where('name|author','like',$param['query'].'%')
            ->where('state',1)
            ->paginate(15);
        $footer = $this->footer();
//        dump($data);
//        dump($param);die;
        $this->assign([
            'data' => $data,
            'footer' => $footer,
            'current' => request()->controller()
        ]);
        return view("index");
    }
    public function footer(){
        $data = db("web") ->cache(true,600)->find();
        return $data;
    }
}